From 607b3d94940693a8f07f79cff71af539eb2017ec Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 13 Nov 2014 16:34:11 +0100 Subject: [PATCH] -l flag no longer pass to binaries if there's a library in the package --- src/cargo/ops/cargo_rustc/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index fef32aff2..43a42a3c6 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -407,6 +407,12 @@ fn rustc(package: &Package, target: &Target, let mut native_lib_deps = native_lib_deps.into_iter().collect::>(); native_lib_deps.sort(); + // If we are a binary and the package also contains a library, then we don't + // pass the `-l` flags. + let pass_l_flag = target.is_lib() || !package.get_targets().iter().any(|t| { + t.is_lib() + }); + (proc(desc_tx: Sender) { let mut rustc = rustc; @@ -419,7 +425,7 @@ fn rustc(package: &Package, target: &Target, for path in output.library_paths.iter() { rustc = rustc.arg("-L").arg(path); } - if id == current_id { + if pass_l_flag && id == current_id { for name in output.library_links.iter() { rustc = rustc.arg("-l").arg(name.as_slice()); } -- 2.30.2